package com.health.mapp.impl;

import java.util.List;

import com.health.db.dto.DoctorListDto;
import com.health.db.model.StuffListExample;
import com.health.db.service.user.IStuffScheduleService;
import com.health.mapp.bean.Header;
import com.health.mapp.bean.QueryAvailableDocListReq;
import com.health.mapp.bean.QueryAvailableDocListResp;
import com.health.mapp.utils.DateUtils;
import com.health.mapp.utils.Response;
import com.health.mapp.utils.ResultCode;

/**
 *  查询医生可预约时间
 * @author HiRoad
 *
 */
public class QueryAvailableDocListImpl implements ActionInterface {
	//private IRegisterOrderService registerOrderService  ;
	
	private  IStuffScheduleService stuffScheduleService;
	
	@Override
	public Response execute(Header header, Object reqBean) throws Exception {
		
		
		QueryAvailableDocListReq req = (QueryAvailableDocListReq) reqBean;
		QueryAvailableDocListResp resp = new QueryAvailableDocListResp();

		String orderDate = req.getOrderDate();
		Integer solt=req.getSolt();
		String orderTime =req.getOrderTime();
		
        
		if (null==solt||null==orderDate) {
			
			resp.setErrorCode(ResultCode.OPERATION_LAKE_PARAMETER_ERROR);
        	resp.setErrorMsg(ResultCode.OPERATION_LAKE_PARAMETER_ERROR_NOTE);
            return resp;
		}
		
        StuffListExample example = new StuffListExample(); 
       
        //在用 0
        example.setIsUsedFlag((short) 0);
        
        //DateUtils
        example.setSolt(String.valueOf(solt)+",");
        example.setWeekday(DateUtils.dayOfWeek(orderDate));
        
        List<DoctorListDto> doctorListDtoList=  stuffScheduleService.selectDocList(example);

        resp.setDocList(doctorListDtoList);
        return resp;
		
	}

	/**
	 * @return the stuffScheduleService
	 */
	public IStuffScheduleService getStuffScheduleService() {
		return stuffScheduleService;
	}

	/**
	 * @param stuffScheduleService the stuffScheduleService to set
	 */
	public void setStuffScheduleService(IStuffScheduleService stuffScheduleService) {
		this.stuffScheduleService = stuffScheduleService;
	}

}
